home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-12 | 4.5 KB | 122 lines | [TEXT/sade] |
- #Name of the window for 'value in context'
- Define __gValueInContextWindowName__
-
- # Given a variable name, this routine displays it in a new window if the name of window
- # will be 32 chars or less
- PROC __PutValueInWindow__(__TheVarName__)
- __gValueInContextWindowName__ := Concat(__ScratchDir__, __TheVarName__)
-
- Define __EvaledVar__ := CheckedEval(__TheVarName__,'Undefined or out of scope: ')
-
- Define __TopOfFile__
- IF Length(__TheVarName__) < 33 THEN
- Redirect __gValueInContextWindowName__
- CheckValidLocalVars
- PrettyPrintValue(__TheVarName__)
- Redirect Pop
- __TopOfFile__ := Selection(__gValueInContextWindowName__,0,0) # Puts cursor at top of window
- ELSE
- __gValueInContextWindowName__ := __gValueWindow__
- Redirect Append __gValueInContextWindowName__
- CheckValidLocalVars
- PrettyPrintValue(__TheVarName__)
- Redirect Pop
- END
- END
-
- # Given a selection (hopefully a field name) in a ShowValue2 window,
- # this routine returns the string 'ParentName.field'
- FUNC __FindVarName__(__TheVarName__)
- IF ActiveWindow = __gValueWindow__ THEN
- # If the selection is in the Value window,
- # we can not guess which variable the user is talking about
- Return __TheVarName__
- END
-
- IF __GetDirectoryFromFullPath__(ActiveWindow) <> __ScratchDir__ THEN
- # The selection is probably in the source code,
- # we can not guess which variable the user is talking about
- Return __TheVarName__
- END
-
- # We will find the leaf name of the window
- Define ParentName := __GetFileFromFullPath__(ActiveWindow)
- # Append the field name to that of its parent struct
- __TheVarName__ := Concat(ParentName, Concat('.', __TheVarName__))
- Return __TheVarName__
- END
-
- # Like Show Value, but try to qualify the selection with a parent name.
- # Also, open a new window if possible
- PROC __HandleShowValue2__(__Selection__)
- CheckNullOrRunningTarget
- __CheckNullSelection__(__Selection__)
- Define __TheVarName__ := __FindVarName__(__Selection__)
- __PutValueInWindow__(__TheVarName__)
- Open __gValueInContextWindowName__
- END
-
- PROC __HandleShowDereferencedValue2__(__Selection__)
- CheckNullOrRunningTarget
- __CheckNullSelection__(__Selection__)
- Define __TheVarName__ := __FindVarName__(__Selection__)
- __CheckPointer__(__TheVarName__)
- __PutValueInWindow__(Concat(__TheVarName__,'^'))
- Open __gValueInContextWindowName__
- END
-
- PROC __SetValue__
- CheckNullOrRunningTarget
- Define __Selection__ := Selection(ActiveWindow)
- __CheckNullSelection__(__Selection__)
- Define __TheVarName__ := __FindVarName__(__Selection__)
- # IF we can not display the value of the variable, we are not going to be able to set it
- Define __EvaledVar__ := CheckedEval(__TheVarName__,'Could not evaluate left hand side :')
- Define __Condition__ := Request(Concat(__TheVarName__, ' = ?'))
- IF __Condition__ = '_CANCEL_' THEN
- ABORT
- END
- Define __EvaledCondition__
- Define __AssignmentExpr__
- Define __EvaledAssignmentExpr__
- IF __Condition__ = '' THEN
- __Fail__('No value was specified, not modified.')
- ELSE
- # check for valid right hand side
- __EvaledCondition__ := CheckedEval(__Condition__, 'Could not evaluate right hand side of assignment: ')
-
- # check for valid condition
- __AssignmentExpr__ := Concat(Concat(__TheVarName__, ' := '), __Condition__)
- __EvaledAssignmentExpr__ := CheckedEval(__AssignmentExpr__, 'Assignment failed.')
- END
- END
-
- PROC __ShowHandleObject__(__Object__)
- CheckNullOrRunningTarget
- __CheckPointer__(__Object__)
- Define __OnceDeref__ := CheckedEval(Concat(__Object__,'^'),'Undefined/Out of scope: ')
- __CheckPointer__(__OnceDeref__)
- __PutValueInWindow__(Concat(__Object__, '^^'))
- Open __gValueInContextWindowName__
- END
-
- PROC __DoubleDeref__
- CheckNullOrRunningTarget
- Define __Handle__ := Selection(ActiveWindow)
- __CheckNullSelection__(__Handle__)
- Define __TheVarName__ := __FindVarName__(__Handle__)
- __CheckPointer__(__TheVarName__)
- Define __OnceDeref__ := CheckedEval(Concat(__TheVarName__,'^'),'Undefined/Out of scope: ')
- __PutValueInWindow__(Concat(__TheVarName__,'^^'))
- Open __gValueInContextWindowName__
- END
-
- Addmenu 'Extras' 'Show Value In Context/2' '__HandleShowValue2__(Selection(ActiveWindow))' # Cmd-2
- Addmenu 'Extras' 'Show Dereferenced Value In Context/3' '__HandleShowDereferencedValue2__(Selection(ActiveWindow))' # Cmd-3
- Addmenu 'Extras' 'Set Value /=' '__SetValue__'
- Addmenu 'Extras' '(-' ''
- Addmenu 'Extras' 'Show **this/4' '__ShowHandleObject__("this")' #For MacApp/C++ programmers
- Addmenu 'Extras' 'Show *this' '__HandleShowDereferencedValue2__("this")' #For non-MacApp/C++ programmers
- Addmenu 'Extras' 'Twice Dereference Selection/5' '__DoubleDeref__'
-
-